package com.prs.crm.domain.purchase;

import java.sql.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;

import com.prs.crm.domain.FlowCodeEntity;
import com.prs.crm.domain.stock.Supplier;
import com.prs.crm.domain.store.StoreRoom;

/**
 * 退货
 * 
 * @author 兰小刚
 * @version 创建时间：2010-7-20 上午11:03:28 类说明
 */
@Entity
@Table(name = "purchase_purchaseReturned")
public class PurchaseReturned extends FlowCodeEntity {

	private static final long serialVersionUID = -4867503240956693033L;
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Integer id;

	/**
	 * 单据编号
	 */
	private String billCode;

	/**
	 * 日期
	 */
	private Date billDate;
	/**
	 * 仓库
	 */
	@ManyToOne
	private StoreRoom rooms;
	/**
	 * 供应商
	 */
	@ManyToOne
	private Supplier supplier;
//	/**
//	 * 入库单
//	 */
//	@ManyToOne
//	private PurchaseStoreIn storeIn;
	/**
	 * 仓管
	 */
	private String roomManager;
	/**
	 * 经手人
	 */
	private String handPerson;
	/**
	 * 退货明细
	 */
	@OneToMany(mappedBy = "purchaseReturned")
	@OrderBy
	@Cascade( { org.hibernate.annotations.CascadeType.ALL,
			org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
	private Set<PurchaseReturnedDetail> details;
	/**
	 * 备注
	 */
	@Lob
	private String remark;

	@ManyToOne
	private FundsInBar fundsInBar;

	@ManyToOne
	private PurchaseReturnedStoreOut purchaseReturnedStoreOut;

	/**
	 * 退货产品批号
	 * 
	 * @return
	 */
	private String btchNum;
	@ManyToOne
	private PurchaseOrder order;


	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getBillCode() {
		return billCode;
	}

	public void setBillCode(String billCode) {
		this.billCode = billCode;
	}

	public Date getBillDate() {
		return billDate;
	}

	public void setBillDate(Date billDate) {
		this.billDate = billDate;
	}

	public StoreRoom getRooms() {
		return rooms;
	}

	public void setRooms(StoreRoom rooms) {
		this.rooms = rooms;
	}

	public Supplier getSupplier() {
		return supplier;
	}

	public void setSupplier(Supplier supplier) {
		this.supplier = supplier;
	}
//
//	public PurchaseStoreIn getStoreIn() {
//		return storeIn;
//	}
//
//	public void setStoreIn(PurchaseStoreIn storeIn) {
//		this.storeIn = storeIn;
//	}

	public String getRoomManager() {
		return roomManager;
	}

	public void setRoomManager(String roomManager) {
		this.roomManager = roomManager;
	}

	public String getHandPerson() {
		return handPerson;
	}

	public void setHandPerson(String handPerson) {
		this.handPerson = handPerson;
	}

	public Set<PurchaseReturnedDetail> getDetails() {
		return details;
	}

	public void setDetails(Set<PurchaseReturnedDetail> details) {
		this.details = details;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public void addDetail(PurchaseReturnedDetail detail) {
		if (details == null)
			details = new HashSet<PurchaseReturnedDetail>();
		detail.setPurchaseReturned(this);
		details.add(detail);
	}

	public FundsInBar getFundsInBar() {
		return fundsInBar;
	}

	public void setFundsInBar(FundsInBar fundsInBar) {
		this.fundsInBar = fundsInBar;
	}

	public PurchaseReturnedStoreOut getPurchaseReturnedStoreOut() {
		return purchaseReturnedStoreOut;
	}

	public void setPurchaseReturnedStoreOut(
			PurchaseReturnedStoreOut purchaseReturnedStoreOut) {
		this.purchaseReturnedStoreOut = purchaseReturnedStoreOut;
	}

	public String getBtchNum() {
		return btchNum;
	}

	public void setBtchNum(String btchNum) {
		this.btchNum = btchNum;
	}

	public PurchaseOrder getOrder() {
		return order;
	}

	public void setOrder(PurchaseOrder order) {
		this.order = order;
	}

	
}
